<?php

/**
 * ECSHOP 商品详情
 * ============================================================================
 * * 版权所有 2005-2012 上海商派网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.ecshop.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: goods.php 17217 2011-01-19 06:29:08Z liubo $
 */

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

/*------------------------------------------------------ */
//-- 晒单详细页展示 by 周全 start
/*------------------------------------------------------ */

if ($_REQUEST['act']=='goods_shaidan_show')
{
    /***热销排行 start**/

    $hot_goods = get_recommend_goods('hot');
    $hot_num = count($hot_goods);

    if($hot_num > 4)
    {
        $i = 0;
        foreach  ($hot_goods as $key => $hot_data)
        {
            if($i<5)
            {
                $hot_goods[$i]=$hot_data;
            }

            $i++;
        }
    }

    $smarty->assign('hot_goods',       $hot_goods);
    //var_dump($hot_goods);
    /***热销排行 end**/

/***推荐商品  start***/
    $best_goods = get_recommend_goods('best');
    $best_num = count($best_goods);

    if($best_num > 3)
    {
        $i = 0;
        foreach  ($best_goods as $key => $best_data)
        {
            if($i<3)
            {
                $best_goods[$i]=$best_data;
            }

            $i++;
        }
    }

    $smarty->assign('best_goods',       $best_goods);

   $smarty->assign('ur_here',       '晒单详情');
   // var_dump($best_goods);
/****推荐商品  end****/
    $goods_id = $_GET['goods_id'];
    $order_id = $_GET['order_id'];
    $sql="select * from ".$GLOBALS['ecs']->table('pic_share')." where goods_id=".$goods_id." and order_id=".$order_id;
    $pic_share =$db->getRow($sql);
    $smarty->assign('share_title', $pic_share['share_title']);
    $smarty->assign('share_content', $pic_share['share_content']);
    $smarty->assign('share_pic', $pic_share['share_pic']);
    $smarty->assign('add_time', $pic_share['add_time']);

    $sql_user ="select * from ".$GLOBALS['ecs']->table('users')." where user_id=".$pic_share['user_id'];
    $pic_user =$db->getRow($sql_user);
    $smarty->assign('user_name', $pic_user['user_name']);

    $sql_gallery = "select * from ".$GLOBALS['ecs']->table('share_gallery')." where goods_id=".$goods_id." and order_id=".$order_id;
    $pic_gallery =$db->query($sql_gallery);
   // var_dump($db->getAll($sql_gallery));
    $gallery = array();
    $img_desc = array();
    $key = 0;
    while ($row = $GLOBALS['db']->fetchRow($pic_gallery))
    {
        $gallery[$key]['img_id']=$row['img_id'];
        $gallery[$key]['img_url']=$row['img_url'];
        $gallery[$key]['img_desc']=$row['img_desc'];
        $key++;
    }
    //var_dump($gallery);
    $smarty->assign('gallery', $gallery);
    $smarty->assign('order_id', $order_id);

    $smarty->assign('helps',        get_shop_help()); // 网店帮助

    assign_template();
    $smarty->display('goods_shaidan.dwt');
}
/*------------------------------------------------------ */
//-- 晒单详细页展示 by 周全 end
/*------------------------------------------------------ */
?>